<template>
  <div class="poptipContent">
    <div class="poptipContent">
      <span>隐私号通话记录</span>
    </div>
    <div class="loadingBox">
      <Spin size="large" fix v-if="callPopLoading" class="spinBox"> </Spin>
      <div style="max-height: 300px; min-height: 40px; overflow-y: auto;padding-right:15px;"
        v-if="callList && callList.length > 0">
        <Timeline>
          <TimelineItem v-for="(item, index) in callList" :key="index">
            <p class="content time">
              <span>{{item.callTime}}</span><span>
                时长：{{item.callDuration}}</span><span class="bgCor"
                v-if="item.unconnectedCause0!='未接通'" @click="audioPlay(item)">播放</span><span
                class="bgCor" v-if="item.unconnectedCause0!='未接通'"
                @click="audioDownload(item)">下载</span>
            </p>
            <p class="content">
              <span>接听状态：{{`${item.unconnectedCause0}(${item.callType})`}}</span>
              <span>通话人：{{item.userName}}</span>
            </p>
          </TimelineItem>
        </Timeline>
      </div>
    </div>
    <dt-audio :transfer="false" ref="dtAudio" />
  </div>
</template>

<script>
  // import customerMgr from '@/biz/customer/customer'
  // import tool from '@/common/tool'
  import toolApi from "@/biz/base/tool";
  export default {
    props: ['callList', 'callPopLoading', ],
    data() {
      return {
        callListCon: [],
      }
    },
    methods: {
      audioPlay(val) {
        if (val.recordUrl) {
          this.$refs.dtAudio.show(val.recordUrl)
        }

      },
      audioDownload(val) {
        if (val.recordUrl) {
          toolApi.downloadFile(val.recordUrl, '音频', '',
            'audio/mpeg;audio/ogg;audio/aac;audio/wav;audio/webm', 'noHomologous');
        }

      },
    },
    created() {},
    watch: {
      callList(val) {
        this.callList = val

        this.callList.forEach(item => {
          let arrList = item.callDuration.split(':')
          let flg = arrList.some(item => {
            return item > 0
          })
          if (!flg) {
            item.callDuration = "--:--:--"
          }

        });
      },
    },
  }
</script>

<style lang="scss" scoped>
  .poptipContent {
    .poptipContent {
      display: flex;
      flex-direction: row;
      justify-content: space-between;
      margin: 10px 0 20px;

      .close {
        color: #2b85e4;
        cursor: pointer;
      }
    }

    .time {
      display: flex;
      flex-direction: row;
      justify-content: space-between;
      color: #999;
    }

    .content {
      display: flex;
      flex-direction: row;
      justify-content: space-between;
      margin-top: 5px;

      .bgCor {
        color: #2b85e4;
        cursor: pointer;
      }

    }
  }

  .transferFooter {
    margin-top: 20px;
    display: flex;
    flex-direction: row;
    justify-content: center;

    button {
      width: 80px;
      margin: 0 10px;
    }
  }

  .loadingBox {
    position: relative;
  }
</style>
<style>
  .popClass {
    display: none;
  }

  .M_poptip {
    position: relative;
  }

  .M_poptip .ivu-poptip-body-content {
    overflow: visible;
  }

  .M_poptip .ivu-poptip-inner {
    background: rgba(235, 247, 255, 1);
  }

  .M_poptip .ivu-icon-ios-help-circle:before {
    display: none;
  }

  .M_poptip .ivu-btn-text {
    position: absolute;
    top: 30px;
    right: 10px;
    color: #0f42a7;
  }

  .M_poptip .ivu-poptip-footer .ivu-btn-primary {
    background: none;
    border: none;
    color: #0f42a7;
    display: none;
  }

  .M_comments {
    position: absolute;
    bottom: 24px;
    left: 33px;
  }

  .spinBox {
    background: rgba(235, 247, 255, 1);
  }
</style>